/**
 * 团购相关接口 
 */
var request = require('./request.js');

module.exports = {
  /**
   * 创建团购活动
   */
  create: function (postData) {
    return request.post('/newretail/api/mall/teamBuyingActivity/create', postData)
  },
  /**
   * 团购活动下单
   */
  createOrder: function (postData) {
    return request.post('/newretail/api/mall/teamBuyingActivity/createOrder', postData)
  },
  /**
   * 查看团购详情
   * @param id 团购活动id
   */
  getGoodsDetails: function (id) {
    var params = {
      id: id
    }
    return request.get('/newretail/api/mall/teamBuyingActivity/getDetails', params)
  },
  /**
   * 查看团购详情
   * @param id 团购活动id
   * @param teamLeaderRecordId 团长团购记录id
   */
  getDetails: function (id, teamLeaderRecordId) {
    var params = {
      id: id,
      teamLeaderRecordId: teamLeaderRecordId
    }
    return request.get('/newretail/api/mall/teamBuyingActivity/getDetails', params)
  },
  /**
   * 查看团购详情
   * @param id 团购活动id
   * @param teamLeaderRecordId 团长团购记录id
   */
  getDetailsByStoreId: function (id, storeId, teamLeaderRecordId) {
    var params = {
      id: id,
      storeId: storeId,
      teamLeaderRecordId: teamLeaderRecordId
    }
    return request.get('/newretail/api/mall/teamBuyingActivity/getDetails', params)
  },
  /**
   * 根据门店id,商品id,团购活动获取该商品正在进行中的团购信息
   * @param storeId 门店id
   * @param productId 商品id
   * @param teamBuyingId 团购活动id
   */
  getOpenTeamBuyings: function (storeId, productId, teamBuyingId) {
    var params = {
      storeId: storeId,
      productId: productId,
      teamBuyingId: teamBuyingId
    }
    return request.get('/newretail/api/mall/teamBuyingActivity/getOpenTeamBuyings', params)
  },
  /**
   * 分页查询团购信息
   * @param page 当前页码，起始于1
   * @param pageSize 每页记录数，必须大于等于0且小于等于100，等于0时表示不分页查询全部数据， 大于0时表示分页查询
   * @param searchCount 是否查询总记录数
   * @param storeId 门店id
   */
  query: function (postData) {
    return request.get('/newretail/api/mall/teamBuyingActivity/query', postData)
  },
  /**
   * 根据门店id查询已提交,已开始的团购活动列表
   * @param storeId 门店id
   */
  getStartedTeamBuyingByStoreId: function (storeId) {
    var params = {
      storeId: storeId
    }
    return request.get('/newretail/api/mall/teamBuyingActivity/getStartedTeamBuyingByStoreId', params)
  },
  /**
   * 删除团购活动
   */
  removeById: function (postData) {
    return request.get('/newretail/api/mall/teamBuyingActivity/removeById', postData)
  },
}